package com.xyw.his00.dto;


import com.fasterxml.jackson.annotation.JsonProperty;
import com.xyw.his00.pojo.dbpojo.PayOrder;

import com.xyw.his00.vo.PatientRequest;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.jackson.Jacksonized;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor

public class InvoiceDTO {
    @JsonProperty("id")
  private Integer id;//id
    @JsonProperty("registerId")
  private Integer registerId;//挂号id
    @JsonProperty("typeId")
  private Integer typeId;//类型id
    @JsonProperty("outTradeNo")
  private String outTradeNo;//订单编号
    @JsonProperty("type")
  private String type;//类型
    @JsonProperty("registerName")
  private String registerName;//患者姓名
        @JsonProperty("orderNo")
  private String orderNo;//病历号
    @JsonProperty("techPrice")
  private BigDecimal techPrice;//单价
    @JsonProperty("totalAmount")
  private BigDecimal totalAmount;//总价
    @JsonProperty("patientRequests")
  private List<PatientRequest> patientRequests;//患者申请表格
    @JsonProperty("subject")
  private String subject;//概要标题
    @JsonProperty("status")
  private String status;//订单状态
    public List<PayOrder> revertToPayOrder() {
        List<PayOrder> payOrders = new ArrayList<>();

      for(PatientRequest patientRequest:patientRequests){
          PayOrder payOrder = new PayOrder();
       payOrder.setId(null);
       payOrder.setRegisterId(getRegisterId());
       payOrder.setTypeId(getTypeId());
       payOrder.setRequestId(patientRequest.getId());
       payOrder.setOrderNumber(getOutTradeNo());
       payOrder.setPatientName(getRegisterName());
       payOrder.setRequestName(getType());
       payOrder.setType(getType());
       payOrder.setTechName(patientRequest.getTechName());
       payOrder.setSubject(getSubject());
       payOrder.setRegisterName(getRegisterName());
       payOrder.setOrderNo(getOutTradeNo());
       payOrder.setTechPrice(patientRequest.getTechPrice());
       payOrder.setCount(patientRequest.getCount());
       payOrder.setTotalAmount(techPrice);
       payOrder.setActualMoney(totalAmount);
       payOrder.setStatus("待支付");
       payOrder.setMoneyType(patientRequest.getPriceType());
       payOrder.setRequestTime(patientRequest.getCreateTime());
       payOrder.setCreationTime(LocalDateTime.now());
       payOrders.add(payOrder);

    }
        return  payOrders;
    }


}
